import {isString} from "./assert";

/**
 * 格式化px
 * @param value
 */
export const getNumberToPx = <T>(value: number | string | T): number | string | T => {
    return value == Number(`${value}`) ? `${value}px` : value;
};

/**
 * 首字母大写
 * @param str
 */
export const firstLetterUpper = (str: string): string => {
    return isString(str) ? str.slice(0, 1).toUpperCase() + str.slice(1) : ""
}

/**
 * 驼峰转中划线
 * @param str
 */
export const camelToKebab = (str: string) => {
    return str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
}